home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / c / qtools0.2-src.lha / src / libqdisplay / surface24.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-10  |  2.1 KB  |  89 lines

  1. static void BuildSky24(struct rgb *out, unsigned char *in)
  2. {
  3.   int size;
  4.  
  5.   for (size = (SKY_X * SKY_Y) - 1; size >= 0; size--)
  6.     *out++ = cachedPalette[*in++];
  7. }
  8.  
  9. static void BuildLightBlock24(struct rgb *out, struct bitmap *raw, int x, int y)
  10. {
  11.   int c, dc;
  12.   int a, b, h, c0, c1, c2, c3;
  13.   int y_max = raw->height, x_max = raw->width;
  14.   unsigned char *fullbright = raw->data + lookup(y, raw->width);
  15.  
  16.   c0 = ((255 << 6) - lightmapIndex[0]);
  17.   c1 = ((255 << 6) - lightmapIndex[1]);
  18.   c2 = ((255 << 6) - lightmapIndex[lightmapWidth]);
  19.   c3 = ((255 << 6) - lightmapIndex[lightmapWidth + 1]);
  20.  
  21.   c2 = (c2 - c0) >> shift;
  22.   c3 = (c3 - c1) >> shift;
  23.  
  24.   for (b = 0; b < step; ++b) {
  25.     h = x;
  26.     c = c0;
  27.     dc = (c1 - c0) >> shift;
  28.     for (a = 0; a < step; ++a) {
  29.       struct rgb pel = cachedPalette[fullbright[h]];
  30.  
  31.       /*int pix; */
  32.       /*if((pix = (pel.r * c) >> (5 + 8)) > 0xFF) */
  33.       /*  pel.r = 0xFF; */
  34.       /*else */
  35.       /*  pel.r = pix; */
  36.       /*if((pix = (pel.g * c) >> (5 + 8)) > 0xFF) */
  37.       /*  pel.g = 0xFF; */
  38.       /*else */
  39.       /*  pel.g = pix; */
  40.       /*if((pix = (pel.b * c) >> (5 + 8)) > 0xFF) */
  41.       /*  pel.b = 0xFF; */
  42.       /*else */
  43.       /*  pel.b = pix; */
  44.       *out++ = pel;
  45.       c += dc;
  46.       if (++h == x_max)
  47.     h = 0;
  48.     }
  49.     out += row;
  50.     c0 += c2;
  51.     c1 += c3;
  52.     if (++y == y_max) {
  53.       y = 0;
  54.       fullbright = raw->data;
  55.     }
  56.     else
  57.       fullbright += raw->width;
  58.   }
  59. }
  60.  
  61. static unsigned short int brightColorshift;
  62. static void BuildBrightBlock24(struct rgb *out, struct bitmap *raw, int x, int y)
  63. {
  64.   int a, b, h;
  65.   int y_max = raw->height, x_max = raw->width;
  66.   unsigned char *fullbright = raw->data + lookup(y, raw->width);
  67.  
  68.   for (b = 0; b < step; ++b) {
  69.     h = x;
  70.     for (a = 0; a < step; ++a) {
  71.       struct rgb pel = cachedPalette[fullbright[h]];
  72.  
  73.       /*pel.r = pel.r >> brightColorshift; */
  74.       /*pel.g = pel.g >> brightColorshift; */
  75.       /*pel.b = pel.b >> brightColorshift; */
  76.       *out++ = pel;
  77.       if (++h == x_max)
  78.     h = 0;
  79.     }
  80.     out += row;
  81.     if (++y == y_max) {
  82.       y = 0;
  83.       fullbright = raw->data;
  84.     }
  85.     else
  86.       fullbright += raw->width;
  87.   }
  88. }
  89.